module Visualization

import vis::Figure;
import vis::Render;
import List;
import Set;
import util::Math;
import IO;
import LinesOfCode;
import CyclomaticComplexity;
import UnitSize;
import Duplicates;
import vis::KeySym;
import Relation;

public void Vis()
{
	from = color("White");
	to = color("Red");
	
	Figures figures = GetBoxes();	
	pack1 = pack(figures, std(gap(8)));
	
	render(pack1);
}

public Figures GetBoxes()
{
	Figures figures = []; 
	from = color("White");
	to = color("Red");
	
	for(int n <- [0 .. 100])
	{
		int width = getOneFrom([1 .. 100]); // Methods
		int height = getOneFrom([1 .. 100]); //LOC
		int cc = getOneFrom([1 .. 100]); // CC%
		real color = percent(cc, 100) / 100.0;
		
		figures += box([size(width, height), fillColor(interpolateColor(from, to, color)), popup(cc, width, height)]);
	}
	
	return figures;
}

public FProperty popup(int riskNum, int methods, linesOfCode)
{
	str risk = "";
	if(riskNum < 10) 
		risk = "Low risk";
	else if (riskNum < 20) 
		risk = "Moderate risk";
	else if (riskNum < 50) 
		risk = "High risk";
	else 
		risk = "Very high risk";
	
	
	t1 = text(risk);
	t2 = text("<riskNum> CC");
	t3 = text("<linesOfCode> lines of code");
	t3 = text("<methods> methods");
	
 	return mouseOver(box(vcat([t1, t2, t3]), fillColor("lightyellow"),
                       grow(1.3), resizable(false), halign(0.9), valign(0.1)));
}





